package LeetCode;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class LC_003_LongestSubstringWithoutRepeatingCharacters {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            System.out.println(lengthOfLongestSubstring(s));
        }
        sc.close();
    }

    private static int lengthOfLongestSubstring(String s) {
        int n = s.length();
        Set<Character> set = new HashSet<>();
        int ans = 0, i = 0, j = 0;
        while (i < n && j < n) {
            // try to extend the range [i, j]
            if (!set.contains(s.charAt(j))) {
                set.add(s.charAt(j++));
                ans = Math.max(ans, j - i);
                System.out.println(j + " " + i + " " + (j - i));
            } else {
                set.remove(s.charAt(i++));
            }
        }
        return ans;
    }
}
